/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 *
 * @author ronald
 */
@Entity
@Table(name = "process_dressmaker_purchase_detail")
public class ProcessDressmakerPurchaseDetail  extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;
    private Double quantity;
    private PurchaseDetail purchaseDetail;
    private ProcessDressmaker processDressmaker;
    private Material material;

    private Double quantityFail;
    private Double priceQuantityFail;
    private Double totalAmountQuantityFail;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id_processdressmaker_purchasedetail")
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_process_dressmaker")
    public ProcessDressmaker getProcessDressmaker() {
        return processDressmaker;
    }

    public void setProcessDressmaker(ProcessDressmaker processDressmaker) {
        this.processDressmaker = processDressmaker;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_purchase_detail")
    public PurchaseDetail getPurchaseDetail() {
        return purchaseDetail;
    }

    public void setPurchaseDetail(PurchaseDetail purchaseDetail) {
        this.purchaseDetail = purchaseDetail;
    }

    @Column(name = "quantity", nullable = false)
    public Double getQuantity() {
        return quantity;
    }

    public void setQuantity(Double quantity) {
        this.quantity = quantity;
    }

    @Column(name = "price_quantity_fail")
    public Double getPriceQuantityFail() {
        return priceQuantityFail;
    }

    public void setPriceQuantityFail(Double priceQuantityFail) {
        this.priceQuantityFail = priceQuantityFail;
    }

    @Column(name = "quantity_fail")
    public Double getQuantityFail() {
        return quantityFail;
    }

    public void setQuantityFail(Double quantityFail) {
        this.quantityFail = quantityFail;
    }

    @Column(name = "total_amount_quantity_fail")
    public Double getTotalAmountQuantityFail() {
        return totalAmountQuantityFail;
    }

    public void setTotalAmountQuantityFail(Double totalAmountQuantityFail) {
        this.totalAmountQuantityFail = totalAmountQuantityFail;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
                   .append(this.id).append(this.quantity)
                   .append(this.purchaseDetail.getId()).append(this.processDressmaker.getId()).toString();

    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ProcessDressmakerPurchaseDetail other = (ProcessDressmakerPurchaseDetail) obj;
        if (this.id != other.getId() && (this.id == null || !this.id.equals(other.getId()))) {
            return false;
        }
        if (this.quantity != other.getQuantity() && (this.quantity == null || !this.quantity.equals(other.getQuantity()))) {
            return false;
        }
        if (this.processDressmaker != other.getProcessDressmaker() && (this.processDressmaker == null || !this.processDressmaker.equals(other.getProcessDressmaker()))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 79 * hash + (this.quantity != null ? this.quantity.hashCode() : 0);
        hash = 79 * hash + (this.purchaseDetail != null ? this.purchaseDetail.hashCode() : 0);
        hash = 79 * hash + (this.processDressmaker != null ? this.processDressmaker.hashCode() : 0);
        return hash;
    }

    @ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
    @JoinColumn(name="id_material")
    public Material getMaterial() {
        return material;
    }

    public void setMaterial(Material material) {
        this.material = material;
    }

}
